package com.ushio.gougouwangguo.controller;

import com.ushio.commonmodule.openfeign.entity.DogCharacterOpnFeign;
import com.ushio.commonmodule.pojo.result.Result;
import com.ushio.commonmodule.pojo.user.User;
import com.ushio.gougouwangguo.entity.qo.DogCharacterEquipmentReplacementQo;
import com.ushio.gougouwangguo.entity.qo.DogCharacterListQo;
import com.ushio.gougouwangguo.entity.vo.DogCharacterVo;
import com.ushio.gougouwangguo.service.DogCharacterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dog-character")
@Tag(name="狗狗角色",description="狗狗角色")
public class DogCharacterController {
    @Autowired
    DogCharacterService dogCharacterService;

    @GetMapping
    @Operation(summary = "查询所有狗狗",description="查询所有狗狗")
    private Result<List<DogCharacterVo>> getDogCharacter(DogCharacterListQo dogCharacterListQo){

        try{

           List<DogCharacterVo> list = dogCharacterService.getDogCharacter(dogCharacterListQo);

            return Result.success(list);

        }catch (Exception e){

            return Result.fail(e.getMessage());

        }
    }

//    @GetMapping
//    @Operation(summary = "查询角色是否使用",description="查询角色是否使用")
//    private void getcheckWhetherTheRoleIsUsed(DogCharacterListQo dogCharacterListQo){
//
//        try{
//
//            dogCharacterService.getcheckWhetherTheRoleIsUsed(dogCharacterListQo);
//
//
//        }catch (Exception e){
//
//
//        }
//    }

    @PostMapping("/stop-the-character-task")
    @Operation(summary = "停止角色任务",description="根据角色id来停止他当前的人物")
    private Result upDataStopTheCharacterTask(DogCharacterListQo dogCharacterListQo){

        try{

            dogCharacterService.upDataStopTheCharacterTask(dogCharacterListQo);
            return Result.success();
        }catch (Exception e){
            e.printStackTrace();

            return Result.fail(e.getMessage());
        }
    }

    //武器替换
    @PostMapping("weapon-replacement")
    @Operation(summary = "武器替换",description = "武器替换")
    private Result<List<DogCharacterVo>> weaponReplacement(@RequestBody DogCharacterEquipmentReplacementQo dogCharacterWeaponReplacementQo){

        try{

             dogCharacterService.weaponReplacement(dogCharacterWeaponReplacementQo);

            return Result.success();

        }catch (Exception e){
            e.printStackTrace();
            return Result.fail(e.getMessage());

        }
    }
    @PostMapping("protective_gear_replacement")
    @Operation(summary = "防具替换",description = "防具替换")
    private Result<List<DogCharacterVo>> protectiveGearReplacement(@RequestBody DogCharacterEquipmentReplacementQo dogCharacterWeaponReplacementQo){

        try{

            dogCharacterService.protectiveGearReplacement(dogCharacterWeaponReplacementQo);

            return Result.success();

        }catch (Exception e){
            e.printStackTrace();
            return Result.fail(e.getMessage());

        }
    }
    @PostMapping("shoe_replacement")
    @Operation(summary = "鞋子替换",description = "鞋子替换")
    private Result<List<DogCharacterVo>> shoeReplacement(@RequestBody DogCharacterEquipmentReplacementQo dogCharacterWeaponReplacementQo){

        try{

            dogCharacterService.shoeReplacement(dogCharacterWeaponReplacementQo);

            return Result.success();

        }catch (Exception e){
            e.printStackTrace();
            return Result.fail(e.getMessage());

        }
    }
    @PostMapping("shoe_replacement-excel")
    @Operation(summary = "鞋子替换",description = "鞋子替换")
    private Result<List<DogCharacterVo>> shoeReplacementExcel(@RequestBody DogCharacterEquipmentReplacementQo dogCharacterWeaponReplacementQo, HttpServletResponse response){

        try{

            dogCharacterService.shoeReplacementExcel(dogCharacterWeaponReplacementQo,response);

            return Result.success();

        }catch (Exception e){
            e.printStackTrace();
            return Result.fail(e.getMessage());

        }
    }

    @PostMapping("/initialize")
    @Operation(summary = "角色初始化",description = "角色初始化")
    private Result<List<DogCharacterOpnFeign>> initializeDogCharacter(@RequestBody User user){

        try{

            List<DogCharacterOpnFeign> dogCharacterVo = dogCharacterService.initializeDogCharacter(user);

            return Result.success(dogCharacterVo);

        }catch (Exception e){
            e.printStackTrace();
            return Result.fail(e.getMessage());

        }
    }
}
